package com.java.controller.api;


import com.java.enums.ReturnMethodEnum;
import com.java.result.Result;
import com.java.service.LendService;
import com.java.utils.Amount1Helper;
import com.java.utils.Amount2Helper;
import com.java.utils.Amount3Helper;
import com.java.utils.Amount4Helper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author Helen
 * @since 2021-07-08
 */

@Api(tags = "标的信息")
@RestController
@RequestMapping("/api/core/lend")
public class LendController {

    @Resource
    private LendService lendService;


    @ApiOperation("获取标的信息")
    @GetMapping("/auth/show/{id}")
    public Result show(@PathVariable Long id) {
        Map<String,Object> map = lendService.getLendDetail(id);
        return Result.ok(map);
    }

    @ApiOperation("计算投资收益")
    @GetMapping("/getInterestCount/{invest}/{yearRate}/{totalMonth}/{returnMethod}")
    public Result getInterestCount(@PathVariable BigDecimal invest,
                                   @PathVariable BigDecimal yearRate,
                                   @PathVariable Integer totalMonth,
                                   @PathVariable Integer returnMethod){
        //有前端传来的还款方式 计算投资收益

        BigDecimal interestCount = lendService.getInterestCount(invest,yearRate,totalMonth,returnMethod);


        return Result.ok(interestCount);
    }



}

